import 'dart:async';

import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

// 常量用户信息key
const _userKey = "USER_KEY";

saveUserData(String value) async {
  final prefs = await SharedPreferences.getInstance();
  await prefs.setString(_userKey, value);
}

Future<String?> getUserData() async {
  final prefs = await SharedPreferences.getInstance();
  final value = prefs.getString(_userKey);
  return value;
}

Future<bool> delUserData() async {
  final prefs = await SharedPreferences.getInstance();
  final res = await prefs.remove(_userKey);
  debugPrint("用户信息删除${res?'成功':'失败'}");
  return res;
}
